package org.ethereum.net.dpos;

import org.ethereum.net.message.Message;
import org.ethereum.net.message.MessageFactory;

/**
 * EOrg message factory
 *
 * @author Shaolin Wu
 * @since 03/10/2018
 */
public class EOrgMessageFactory implements MessageFactory {

    @Override
    public Message create(byte code, byte[] encoded) {

    		EOrgMessageCodes receivedCommand = EOrgMessageCodes.fromByte(code);
        switch (receivedCommand) {
            case VOTE_REQUEST:
                return new EOrgVoteRequest(encoded);
            case VOTE_RESPONSE:
                return new EOrgVoteResponse(encoded);
            default:
                throw new IllegalArgumentException("No such message");
        }
    }
}
